﻿using System;
using System.Collections.Generic;

using DreamCube.Foundation.Serialization;

namespace DreamCube.Websites.EasyUIModel
{
    /// <summary>
    /// id: 绑定到节点的标识值. 
    /// text:显示文本. 
    /// iconCls: 显示icon的css样式. 
    /// checked: 节点是否选中. 
    /// state: 节点状态, 'open' 或者 'closed'. 
    /// attributes: 绑定到节点的自定义属性. 
    /// target: 目标 DOM 对象. 
    /// </summary>
    public class TreeNode
    {
        #region "内部枚举"

        /// <summary>
        /// 树节点的状态
        /// </summary>
        public enum TreeNodeState
        {
            /// <summary>
            /// 展开状态
            /// </summary>
            open,
            /// <summary>
            /// 关闭状态
            /// </summary>
            closed
        }

        #endregion

        #region "字段"

        private String state = "open";
        private TreeNodeState treeNodeState = TreeNodeState.open;
        private List<TreeNode> childrenNode = null;

        #endregion

        #region "属性"

        /// <summary>
        /// 树节点状态
        /// </summary>
        [JsonIgnore]
        public TreeNodeState NodeState
        {
            get { return treeNodeState; }
            set 
            {
                treeNodeState = value;
                this.state = treeNodeState.ToString();
            }
        }

        /// <summary>
        /// 节点状态
        /// </summary>
        public String State
        {
            get { return state; }
        }

        /// <summary>
        /// 绑定到节点的标识值
        /// </summary>
        public Int32 ID
        {
            get;
            set;
        }

        /// <summary>
        /// 显示文本
        /// </summary>
        public String Text
        {
            get;
            set;
        }

        /// <summary>
        /// 节点是否选中
        /// </summary>
        public Boolean Checked
        {
            get;
            set;
        }

        /// <summary>
        /// 显示icon的css样式
        /// </summary>
        public String IconCls
        {
            get;
            set;
        }

        /// <summary>
        /// 子节点
        /// </summary>
        public List<TreeNode> ChildrenNode
        {
            get { return childrenNode; }
            set { this.childrenNode = value; }
        }

        #endregion
    }
}
